package com.sc.nft.controller;

import com.sc.nft.annotation.UserLogin;
import com.sc.nft.entity.WxMiniUserInfo;
import com.sc.nft.feign.WxMiniUserPointsClient;
import com.sc.nft.pool.UserPool;
import com.sc.nft.req.points.webPointsGetReq;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import com.sc.nft.vo.points.webPointsGetVO;
import com.sc.nft.vo.points.webPointsRecordsVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/ipMall/wxMiniMall/points/user")
@Api(tags = "小程序个人中心用户积分")
public class WxMiniUserPointsController{

    private final WxMiniUserPointsClient wxMiniUserPointsClient;


    /**
     * 个人积分详情
     * @return
     */
    @PostMapping(value = "/get", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "个人积分详情")
    @UserLogin
    public Result<webPointsGetVO> webGet(@RequestBody webPointsGetReq request) {
        WxMiniUserInfo wxUser = UserPool.getWxMiniUser();
        request.setMiniUserId(wxUser.getId());
        return wxMiniUserPointsClient.webGet(request);
    }



    /**
     * 个人积分明细
     * @return
     */
    @PostMapping(value = "/records", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "个人积分明细")
    @UserLogin
    public PageResult<webPointsRecordsVO> records(@RequestBody webPointsGetReq request) {
        WxMiniUserInfo wxUser = UserPool.getWxMiniUser();
        request.setMiniUserId(wxUser.getId());
        return wxMiniUserPointsClient.records(request);
    }

}